<?php

class PHPMutagen_Generator
{

    protected $_runner = null;
    protected $_files = array();
    protected $_mutables = array();
    protected $_mutableFileClass = 'PHPMutagen_MutableFile';

    public function __construct(PHPMutagen_Runner $runner) 
    {
        $this->_runner = $runner;
    }

    public function generate() 
    {
        $files = $this->_runner->getFiles();
        foreach ($files as $file) {
            if (!preg_match("/\.php$/", $file)) {
                continue;
            }
            $mutableFile = new $this->_mutableFileClass($file);
            $mutableFile->generateMutations();
            if ($mutableFile->hasMutations()) {
                $this->_mutables[] = $mutableFile;
            }
        }
    }

    public function getMutables() 
    {
        return $this->_mutables;
    }

    public function setMutableFileClass($class) 
    {
        $this->_mutableFileClass = $class;
    }

}